<?php
declare (strict_types=1);

namespace Plugin\Organization\Model;

use App\Model\Permission\User;
use Mine\MineModel;

class RdOrganizeUserStand extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_organize_user_stand';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'user_id', 'stand_id', 'role', 'status', 'created_by', 'updated_by', 'created_at', 'updated_at', 'remark'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'user_id' => 'integer',
        'stand_id' => 'integer',
        'role' => 'integer',
        'status' => 'integer',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    /**
     * 关联用户
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    /**
     * 关联站点
     */
    public function stand()
    {
        return $this->belongsTo(RdOrganizeAreaStand::class, 'stand_id');
    }
}